package com.open.capacity.notice.provider.wechat;

import java.io.IOException;
import java.util.function.Consumer;

import com.open.capacity.notice.provider.wechat.interactive.req.SendFileRequest;
import com.open.capacity.notice.provider.wechat.interactive.req.SendTextRequest;
import com.open.capacity.notice.provider.wechat.interactive.res.SendFileResponse;
import com.open.capacity.notice.provider.wechat.interactive.res.SendTextResponse;

/**
 * 微信异步请求
 *
 */
public class AsyncWechatOperations extends WechatOperations {
	public AsyncWechatOperations(WechatTemplate wechatTemplate) {
		super(wechatTemplate);
	}

	public void sendText(SendTextRequest sendTextRequest, Consumer<SendTextResponse> success,
			Consumer<IOException> failure) throws IOException {
		super.asyncPost(WechatApiAddress.SEND_TEXT, true, sendTextRequest, SendTextResponse.class, success, failure,
				wechatTemplate.getWechatProperties().getHost());
	}

	public void sendFile(SendFileRequest sendTextRequest, Consumer<SendFileResponse> success,
			Consumer<IOException> failure) throws IOException {
		super.asyncPost(WechatApiAddress.SEND_FILE, true, sendTextRequest, SendFileResponse.class, success, failure,
				wechatTemplate.getWechatProperties().getHost());
	}

}
